package com.zfp.sslserver.controller.grpc;

import com.zfp.sslserver.grpc.SslTestSrvGrpc;
import com.zfp.sslserver.grpc.Ssltest;
import io.grpc.stub.StreamObserver;
import org.springframework.stereotype.Service;

/**
 * Created by zfp on 17-11-20.
 * contact : zfpyz2011@gmail.com
 */
@Service(value = "SslTestGrpcController")
public class SslTestGrpcController extends SslTestSrvGrpc.SslTestSrvImplBase {

    @Override
    public void sslTest(Ssltest.TestReq request, StreamObserver<Ssltest.TestRes> responseObserver) {
        String req = request.getReq();
        System.out.println(String.format("GRPC-REQ:%s", req));

        responseObserver.onNext(Ssltest.TestRes.newBuilder().setRes(String.format("RES:%s", req)).build());
        responseObserver.onCompleted();
    }
}
